<?php

namespace mpend\modules\user\models;

use Yii;
use common\helpers\Url;

/**
 * 会员栏信息
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class MemberAboutLogic extends \common\models\member\Member {

    /**
     * @inheritdoc
     */
    public function getPanel() {
        //永久黑名单
        if ($this->isBlack) {
            return null;
        }
        $typename = $this->type ? $this->type->name : '';
        //有效
        if ($this->isAvaild) {
            return [
                'icon' => Url::attach('assets/icons/crown.png'),
                'title' => '优越定制',
                'subtitle' => $typename,
                'description' => '分享、下单即可以享受 ' . $this->scale * 10 . '折 优惠',
                'weblink' => Url::weblink('commission'),
                'extra' => [
                    'text' => '会员中心',
                    'weblink' => null,
                ]
            ];
        }

        return null;
    }

    public function getHurdle() {
        //申请中
        if ($this->isApplying) {
            return [
                'icon' => Url::attach('assets/icons/crown.png'),
                'title' => '会员申请中',
                'button' => '查看进度',
                'user_id' => $this->user_id,
                'weblink' => Url::weblink('member')
            ];
        }
        return null;
    }

    public static function promptApply() {
        return [
            'icon' => Url::attach('assets/icons/crown.png'),
            'title' => '优越会员',
            'button' => '申请开通',
            'weblink' => Url::weblink('member/service')
        ];
    }

}
